<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="UTF-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0" />
        <title>Document</title>
    </head>
    <body>
        <script>
            /* 说是子序列，其实就是子集，而且它不是求个数，因此只能用回溯 */
            var findSubsequences = function (nums) {
                let res = []
                let map = new Map()

                function backTracking(path, start) {
                    if (start > nums.length) return
                    if (path.length > 1) {
                        let str = path.join("")
                        if (!map.has(str)) {
                            map.set(str, 1)
                            res.push([...path])
                        }
                    }
                    for (let i = start; i < nums.length; i++) {
                        if (path.length == 0 || nums[i] >= path[path.length - 1]) {
                            path.push(nums[i])
                            backTracking(path, i + 1)
                            path.pop()
                        }
                    }
                }
                backTracking([], 0)
                return res
            }
        </script>
    </body>
</html>
